﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;


namespace MVVM.Core
{
    public static class ViewModelFactory
    {
        public static ViewModelBase CreateViewModel<Tvm, Tv>(Tvm viewModel = null)
            where Tvm: ViewModelBase, new()
            where Tv: ContentControl, new()
        {
            Tv view = new Tv();

            if (viewModel == null)
                viewModel = new Tvm();
            
            viewModel.View = view;
            
            return viewModel;
        }
    }
}
